<template>
  <div class="dialog">
    <el-dialog
      :title="titleText"
      :visible.sync="showDialog"
      width="35%"
      top="0"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <div class="showTag">
        <el-tag
          v-for="(item,idx) in showOptions"
          :key="idx"
          class="showTag-item"
        >{{ item.equipmentName }}</el-tag>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelbtn" @click="cancel()">取 消</el-button>
        <el-button type="primary" class="savebtn" @click="save()">保 存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "ShowDialog",
  props: {
    // 弹框名称
    titleText: {
      type: String,
      default: ""
    },
    show: {
      type: Boolean,
      default: false
    },
    showOptions: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data() {
    return {
      showDialog: this.show
    };
  },
  watch: {
    show(v) {
      this.showDialog = v;
    }
  },
  mounted() {
    console.log(this.showOptions);
  },
  methods: {
    close() {
      this.$emit("closeShowDialog");
    },
    save() {
      this.$emit("closeShowDialog");
    },
    cancel() {
      this.$emit("closeShowDialog");
    }
  }
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  max-height: 500px;
  overflow-y: auto !important;
  overflow-x: hidden;
}
.showTag {
  display: flex;
  flex-direction: row;
  .showTag-item {
    margin-right: 12px;
  }
}
</style>
